package com.gizwits.akka

import akka.actor.{Actor, ActorSystem, Props}
import akka.event.Logging


case class Msg(msg: String)


class ParentActor extends Actor {

  val log = Logging.getLogger(context.system, this)

  override def receive: Receive = {

    case Msg(msg) => {
      log.info("start child actort")

      val p2 = context.actorOf(Props[ChildActor], name = "p2")
      p2 ! msg

    }
    case _ => {

      log.info("no msg macth!!!")
    }

  }
}


class ChildActor extends Actor {
  val log = Logging.getLogger(context.system, this)

  override def receive: Actor.Receive = {
    case msg: String => {

      log.info(msg)

      context.system.shutdown

    }
    case _ => {
      log.info("no child msg macth ")

    }

  }


}


object ParentChildActor {

  def main(args: Array[String]) {


    val system = ActorSystem("sys")
    val p1 = system.actorOf(Props[ParentActor], name = "p1")
    p1 ! Msg("hello feel")



  }

}
